<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%@ include file="/resource/include/link_css.jsp"%>
<%@ include file="/resource/include/hander.jsp"%>

<%@ include file="/resource/include/sidebar.jsp"%>


<div class="content-inner">
    <!-- Page Header-->
    <header class="page-header">
        <div class="container-fluid">

        </div>
    </header>
    <!-- Breadcrumb-->
    <div class="breadcrumb-holder container-fluid">
        <ul class="breadcrumb">

        </ul>
    </div>
    <!-- Forms Section-->
    <section class="forms">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-1">

                </div>
                <!-- Basic Form-->
                <div class="col-lg-9">
                    <div class="card">
                        <div class="card-header d-flex align-items-center">
                            <h3 class="h4">调查问卷列表</h3>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>名称</th>
                                        <th>题数</th>
                                        <th>发布时间</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                        <c:forEach  items="${pageInfo.list}" var="naire">

                                        <tr>
                                            <td >${naire.questionnairetitle}</td>
                                            <td>${naire.score}</td>
                                            <td>
                                                <fmt:formatDate value="${naire.submittime}" pattern="yyyy/MM/dd HH:mm:ss" />
                                            </td>
                                            <td>
                                                <c:if test="${naire.status==1}">已发布</c:if>
                                                <c:if test="${naire.status==0}">未发布</c:if>
                                            </td>
                                            <td>
                                                <c:if test="${naire.status==1}">
                                                    <button class="btn btn-primary" onclick="fenxi(${naire.nid})">查看分析</button>
                                                    <button class="btn btn-primary" onclick="deletebyId(${naire.nid})">撤回问卷</button>
                                                </c:if>
                                                <c:if test="${naire.status==0}">
                                                    <button class="btn btn-primary" onclick="yulan(${naire.nid})" >预览问卷</button>
                                                    <button class="btn btn-primary" onclick="fabu(${naire.nid})">发布问卷</button>
                                                </c:if>
                                            </td>
                                        </tr>
                                        </c:forEach>
                                    </tbody>
                                    <form  action="statistics.do" method="post" id="fenxi">
                                        <input type="hidden" name="nid" id="nid">
                                    </form>
                                </table>
                            </div>
                        </div>


                    </div>
                </div>

            </div>
        </div>
    </section>

</div>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script type="text/javascript" >
    function fenxi(nid){

        $("#nid").val(nid);

        $("#fenxi").submit();
    }

    function deletebyId(id) {

            $.ajax({
                url:"delenaire.do",
                dataType:"json",
                type:"post",
                data:{
                    nid:id
                },
                success:function (data) {
                    alert(data.msg);
                    window.history.back();
                    location.reload();
                }
            });
    }
    function yulan(id){
        $("#question").submit()
        var x = window.screen.height;
        var y = window.screen.width;
        var h = 600;
        var w = 700;
        var model = "title=word,resizable=yes,scrollbars=yes," +
            "height=" + h + ",width=" + w + ",status=no,toolbar=no" +
            ",menubar=no,location=no,top=" + (x-h)/4 + ",left=" + (y-w)/2;

        var url = "naire_show.do/"+id;//弹出窗口的页面内容
        var oOpen = window.open(url,"adviceDetail",model);
        oOpen.focus();
    }
    function fabu(nid){
      window.location.href="releasenaire.do/"+nid;
    }
</script>
<%@ include file="/resource/include/link_js.jsp"%>